package com.lhy;

        import java.util.HashMap;

public class Test60 {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1,"一");
        map.put(2,"二");
        map.put(3,"三");
        map.put(4,"四");
        //删除集合3的元素，后该位置为空。
        map.remove(3);
        //遍历输出key和value
        for (Integer i : map.keySet() ){
            System.out.println("key: "+i+"and value: "+map.get(i));
        }
        System.out.println(map);
        System.out.println(map.size());
        System.out.println(map.get(3));//通过键获取值
        map.clear();//删除集合
        System.out.println(map);
    }

}
